/*
 * @Author: 李石
 * @Date: 2024-04-28 18:13:35
 * @LastEditors: lishi
 * @LastEditTime: 2024-05-21 11:52:55
 * @Description: 
 * Copyright (c) 2024 by ${lishi0105@163.com}, All Rights Reserved. 
 */
#ifndef UTILS_PP_HPP
#define UTILS_PP_HPP

#include <iostream>
#include <cstdarg>
#include <cmath>

class UtilsPP {
public:
    UtilsPP() = delete;
    ~UtilsPP() = delete;
    UtilsPP(const UtilsPP &) = delete;
    UtilsPP &operator=(const UtilsPP &) = delete;
    static std::string formatString(const char* format, ...);
    static std::string  exec(const char* cmd, bool runInBackground = false);
    static bool isValidMediaUrl(const std::string &url);
    static bool isValidString(const std::string& str);
};

class FloatComparer {
public:
    static bool float_less(float a, float b, float epsilon = 1e-6) {
        return (b - a) > epsilon;
    }

    static bool double_less(double a, double b, double epsilon = 1e-9) {
        return (b - a) > epsilon;
    }

    static bool float_equal(float a, float b, float epsilon = 1e-6) {
        return std::fabs(a - b) < epsilon;
    }
    static bool double_equal(double a, double b, double epsilon = 1e-9) {
        return std::fabs(a - b) < epsilon;
    }
};

#endif  // UTILS_PP_HPP